const app = getApp()
Component({

    /**
     * 组件的属性列表
     */
    properties: {

    },

    /**
     * 组件的初始数据
     */
    data: {
      filterData:[],
      tableData:[],
      queryValue:'',
    },

    /**
     * 组件的方法列表
     */
    methods: {
      getTableData(){
        app.func.request({
          url: '/finance/budget/page',
          data:{},
          success: ({data})=>{
            this.setData({
              tableData: data,
              filterData: data
            })
          }
        })
      },
      doToSinglePage(e){
        const id = e.currentTarget.dataset.id
        wx.navigateTo({
          url: `./dialog/index?id=${id}`,
        })
      },
      queryInput(e){
        const filterData = this.data.tableData.filter(row=>{
            return row.skuName.indexOf(this.data.queryValue)>-1 || row.skuTitle.indexOf(this.data.queryValue)>-1 
        });
        this.setData({
          filterData: filterData
        });
      },
    },
    pageLifetimes:{
      show: function () {
        this.getTableData()
       },
    },
    ready: function() {
      wx.setNavigationBarTitle({
        title: '单品测算',
      })
    },
})